package com.atguigu.gmall.search.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.search.Goods;
import com.atguigu.gmall.search.service.SearchService;
import com.atguigu.gmall.search.vo.SearchParamVo;
import com.atguigu.gmall.search.vo.SearchRespVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author lhh
 * @ClassName SearchRpcController
 * @date 2022 2022/12/12
 */

@RestController
@RequestMapping("/api/inner/rpc/search")
public class SearchRpcController {

    @Resource
    SearchService searchService;


    /**
     * 商品检索
     * @param searchParamVo
     * @return
     */
    @PostMapping("/searchgoods")
    public Result<SearchRespVo> search(@RequestBody SearchParamVo searchParamVo){
        SearchRespVo searchRespVo=searchService.search(searchParamVo);
        return Result.ok(searchRespVo);
    }
    /**
     * 下架
     * @param skuId
     * @return
     */
    @GetMapping("/down/goods/{skuId}")
    public Result down(@PathVariable Long skuId){
        searchService.down(skuId);
        return Result.ok();
    }

    /**
     * 上架
     * @param goods
     * @return
     */
    @PostMapping("up/goods")
    public Result up(@RequestBody Goods goods){
        searchService.up(goods);
        return Result.ok();
    }

    /**
     * 增加热度分
     */
    @GetMapping("/hotscore/{skuId}/{score}")
    public Result updateHotScore(@PathVariable Long skuId,@PathVariable Long score){
        searchService.updateHotScore(skuId,score);
        return Result.ok();
    }

}
